﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


   /*定义一个学生类，存放学生的学号、姓名、性别、年龄、专业信息；
   对年龄字段进行赋值的安全性设置，如果是非法值（小于0或者大于128岁），该年龄值为0；
   在学生类中定义一个方法输出学生信息。*/


namespace ConsoleApp1
{
    class Student
    {
        public string StuID { get; set; }
        public string StuName { get; set; }
        public string StuGender { get; set; }

        public string StuZhuanYe { get; set; }

        private int StuAge;

       

        public Student()
        {
        }

        public Student(string stuID, string stuName, string stuGender, string stuZhuanYe, int stuAge)
        {
            StuID = stuID;
            StuName = stuName;
            StuGender = stuGender;
            StuZhuanYe = stuZhuanYe;
            if (stuAge < 0 || stuAge > 128)
            {
                this.StuAge = 0;
            }
            else
            {
                this.StuAge = stuAge;
            }
        }

        public int StuAge1
        {
            get => this.StuAge;
            set
            {
                if (value < 0 || value > 128)
                {
                    this.StuAge = 0;
                }
                else
                {
                    this.StuAge = value;
                }
            }
        }

        public void show() {
            Console.WriteLine($"{StuName}{StuID}{StuGender}{StuZhuanYe}{StuAge}"); 
        }


    }
}
